package com.huike.contract.mapper;

import com.huike.contract.domain.TbContract;
import com.huike.contract.domain.vo.CountActivityId;
import com.huike.contract.domain.vo.GetAmountWithCost;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 合同Mapper接口
 * @date 2021-05-19
 */
@Mapper
public interface TbContractMapper {


    public TbContract selectTbContractById(Long id);

    /**
     * 查询合同列表
     *
     * @param tbContract 合同
     * @return 合同集合
     */
    public List<TbContract> selectTbContractList(TbContract tbContract);

    /**
     * 新增合同
     *
     * @param tbContract 合同
     * @return 结果
     */
    public int insertTbContract(TbContract tbContract);

    /**
     * 修改合同
     *
     * @param tbContract 合同
     * @return 结果
     */
    public int updateTbContract(TbContract tbContract);

    /**
     * 删除合同
     *
     * @param id 合同ID
     * @return 结果
     */
    public int deleteTbContractById(Long id);

    /**
     * 批量删除合同
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteTbContractByIds(Long[] ids);
//
    /**
     * 合同总数
     * @param beginTime
     * @param endTime
     * @return
     */
    int getContracyNums(@Param("beginTime") LocalDateTime beginTime,@Param("endTime") LocalDateTime endTime);

    Double saleStatistics(Map map);
    /**
     * 客户折线图
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    List<Map<String, Object>> contractStatistics(@Param("beginCreateTime") String beginCreateTime,@Param("endCreateTime") String endCreateTime);

    /**
     * 客户学科统计
     * @param beginCreateTime
     * @param endCreateTime
     * @param
     * @return
     */
    //查询各个学科和学科对应的人数
    public List<Map<String,Object>> subject(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime,@Param("status") Integer status);
    /**
     * 根据活动表id获取合同表
     * @param id
     * @return
     */
    @Select("select * from tb_contract where activity_id = #{id}")
    TbContract getByActivityId(Long id);

    @Select("select * from  tb_contract where activity_id = #{id}")
    List<TbContract> getAmount(Long id);

    List<CountActivityId> getContract(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);

    /**
     * 查询活动成交客户数量
     * @param activityId
     * @return
     */
    @Select("select count(*) from tb_contract where activity_id = #{activityId}")
    Integer getNumByActivityId(Long activityId);

    GetAmountWithCost getAmountWithCost(TbContract tbContract);

}
